<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <title>忧郁小王子-评论列表</title>
  <link rel="stylesheet" href="/admin/assets/vendors/bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="/admin/assets/vendors/font-awesome/css/font-awesome.css">
  <link rel="stylesheet" href="/admin/assets/vendors/nprogress/nprogress.css">
  <link rel="stylesheet" href="/admin/assets/css/admin.css">
  <script src="/admin/assets/vendors/nprogress/nprogress.js"></script>
</head>
<body>
  <script>NProgress.start()</script>

  <div class="main">
    {{include '../common/header.html'}}
    <div class="container-fluid">
      <div class="page-title">
        <h1 style="font-size: 30px">评论列表</h1>
        <a href="#" style="margin-left: 100px;color: red">{{message}}</a>
      </div>
      <div class="page-action">
        <!-- show when multiple checked -->
        <a class="btn btn-danger btn-sm" href="javascript:;" style="display: none">批量删除</a>
        <form class="form-inline" method="post" action="/admin/getComment">
          <select name="state" class="form-control input-sm">
            <option value="2">所有状态</option>
            <option value="1">已批准</option>
            <option value="0">未批准</option>
          </select>
          <button class="btn btn-default btn-sm" type="submit">筛选</button>
        </form>
        <ul class="pagination pagination-sm pull-right">
          {{if comments.page > 1}}
          <li>
            <a href="/admin/toCommentListPage?page={{comments.page - 1}}">上一页</a>
          </li>
          {{/if}}
          {{each comments.display}}
          {{if $value == comments.page}}
          <li><a style="color: red" href="/admin/toCommentListPage?page={{$value}}">{{$value}}</a></li>
          {{else if $value != comments.page}}
          <li><a href="/admin/toCommentListPage?page={{$value}}">{{$value}}</a></li>
          {{/if}}
          {{/each}}
          {{if comments.page < comments.pages}}
          <li>
            <a href="/admin/toCommentListPage?page={{comments.page - 0 + 1}}">下一页</a>
          </li>
          {{/if}}
        </ul>
      </div>
      <table class="table table-striped table-bordered table-hover">
        <thead>
          <tr>
            <th class="text-center h4">作者</th>
            <th class="text-center h4">评论内容</th>
            <th class="text-center h4">评论文章</th>
            <th class="text-center h4">评论时间</th>
            <th class="text-center h4">状态</th>
            <th class="text-center h4" width="150">操作</th>
          </tr>
        </thead>
        <tbody>
        {{each comments.records}}
          <tr>
            <td class="text-center">{{$value.uid.username}}</td>
            <td class="text-center">{{$value.content}}</td>
            <td class="text-center">《{{$value.aid.title}}》</td>
            <td class="text-center">{{dateFormat($value.time,'yyyy-mm-dd HH:mm:ss')}}</td>
            {{if $value.state == 1}}
            <td class="text-center"><a href="javascript:;" class="btn btn-success btn-xs">已批准</a></td>
            {{else}}
            <td class="text-center"><a href="javascript:;" class="btn btn-warning btn-xs">未批准</a></td>
            {{/if}}
            <td class="text-center">
              {{if $value.state == 1}}
              <a href="/admin/modifyCommentState?id={{@$value._id}}" class="btn btn-warning btn-xs">驳回</a>
              {{else}}
              <a href="/admin/modifyCommentState?id={{@$value._id}}" class="btn btn-success btn-xs">批准</a>
              {{/if}}
              <a href="javascript:;" class="btn btn-danger btn-xs" onClick="javascript:if(del()) location.href='/admin/deleteComment?id={{@$value._id}}'">删除</a>
            </td>
          </tr>
        {{/each}}
        </tbody>
      </table>
    </div>
  </div>

  {{include '../common/leftMenu.html'}}

  <script src="/admin/assets/vendors/jquery/jquery.js"></script>
  <script src="/admin/assets/vendors/bootstrap/js/bootstrap.js"></script>
  <script>
    NProgress.done();
    function del(){
      let message = confirm("您确定要删除该改用户吗？");
      if (message == true){
        return true;
      }else{
        return false;
      }
    }
  </script>
</body>
</html>
